package com.kerrykidz.system.util.security;

import org.apache.shiro.authz.Permission;

/**
 * 
 * @ClassName: ElementPermission
 * @description: Shiro的权限资源
 * @author: QUINN
 * @date: 2014年6月23日 下午5:09:07
 * @version: V1.0
 * 
 */
public class ElementPermission implements Permission {

	public ElementPermission(String name, String url) {
		this.name = name;
		this.url = url;
	}

	private String name;

	private String url;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public boolean implies(Permission p) {
		if (p instanceof ElementPermission) {
			ElementPermission ep = (ElementPermission) p;
			return ep.getUrl().equals(this.url) && ep.getName().equals(this.name);
		}
		return false;
	}

	@Override
	public int hashCode() {
		return (this.url + this.name).hashCode();
	}

	@Override
	public boolean equals(Object obj) {
		return this == obj;
	}

}
